from django.http import HttpResponse
from rest_framework import viewsets

from appBackend.models import CurrencyExchangeRateRecords
from appBackend.serializers import CurrencyExchangeRateRecordsSerializer
from appBackend.utils import CurrencyExchangeRateUtils


class CurrencyExchangeRateRecordsViewSet(viewsets.ModelViewSet):
    queryset = CurrencyExchangeRateRecords.objects.all()
    serializer_class = CurrencyExchangeRateRecordsSerializer


def get_newest_currency_exchange_rate(request):
    CurrencyExchangeRateUtils.get_newest_rate()
    return HttpResponse({"status": "ok"})
